# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=stylus
pkgdesc='Robust, expressive, and feature-rich CSS superset'
pkgver=0.60.0
pkgrel=1
arch=('any')
url='https://github.com/stylus/stylus'
license=('MIT')
depends=('nodejs')
makedepends=('npm' 'git')
source=(https://registry.npmjs.org/$pkgname/-/$pkgname-$pkgver.tgz)
noextract=($pkgname-$pkgver.tgz)
sha512sums=('8f6a41804c330aed39c82b98e1c9b2a7416d3d040504100607b4d8ed068d97b7b3b621f0931cf0bc8a79be3649343fdad4934e91af995bd7b054f159a48de970')

package() {
  npm install -g --prefix "$pkgdir"/usr "$srcdir"/$pkgname-$pkgver.tgz

  # Non-deterministic race in npm gives 777 permissions to random directories.
  # See https://github.com/npm/npm/issues/9359 for details.
  chmod -R u=rwX,go=rX "$pkgdir"

  # npm installs package.json owned by build user
  # https://bugs.archlinux.org/task/63396
  chown -R root:root "$pkgdir"

  mkdir -p "$pkgdir/usr/share/licenses/$pkgname"
  ln -s "../../../lib/node_modules/$pkgname/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/"
}
